package com.doit.day04

import scala.io.Source

object _02_wordCount {
  def main(args: Array[String]): Unit = {
    val list: List[String] = Source.fromFile("D:\\develop\\ideaWorkSpace\\doit45\\data\\word.txt").getLines().toList
    val res: List[String] = list.flatMap(_.split(","))
    //    res.foreach(println)
    val group: Map[String, List[String]] = res.groupBy(word => word)
    val res2: Map[String, Int] = group.map(tp => {
      val key: String = tp._1
      val size: Int = tp._2.size
      (key, size)
    })
    res2.foreach(println)
  }

}
